<?php
@session_start();
$width  = 40;
$height = 16;
$code   = rand(1000,9999);

$im = imagecreatetruecolor($width,$height);
$green = imagecolorallocate($im,0,255,0);
$black = imagecolorallocate($im,0,0,0);

imagefill($im,0,0,$black);
imagecolortransparent($im,$black);
imagestring($im,4,2,2,$code,$green);

Header('Content-Type: image/png');
imagepng($im);
$_SESSION['code'] = $code;

ImageDestroy($im);
?>